package com.sinas;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Sinas
 */
public class TimerAffichage extends Thread {
    private boolean sleep = false;
    private boolean vu = true;
    private int cpt=0;
    private int cptTour = 0;

    public TimerAffichage()
    {
    }

    public void sleepToi() {
        sleep = true;
    }

    public void run() {
        while (true) {
            try {
                if(!sleep)
                {
                    cpt++;
                }
                else
                {
                    cpt = 0;

                    if(!vu)
                    {
                        cptTour++;    
                        vu = true;
                    }
                }
                sleep = false;
                Thread.sleep(1000);
                if(cpt == 4 & !sleep)
                {
                    vu = false;
                    for(int i=0; i<8; i++)
                    {
                        if(SinasGuiHostApplication.plots[i]!= null)
                        {
                            DataWindow dw = SinasGuiHostApplication.plots[i];
                            dw.visibilite.setSelected(false);
                        }
                    }

                    cpt = 0;
                }
                else
                {
                    for(int i=0; i<8; i++)
                    {
                        if(SinasGuiHostApplication.plots[i]!= null)
                        {
                            DataWindow dw = SinasGuiHostApplication.plots[i];
                            dw.lblNbTour.setText(""+cptTour);
                        }
                    }
                }
            } catch (InterruptedException ex) {
                Logger.getLogger(TimerAffichage.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
